Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect users locale and custom date- and time-formats in sent emails #922

Conversation

carstingaxion
Copy link
Collaborator

@carstingaxion carstingaxion commented Sep 26, 2024

Fragmentation of #752

Until this PR, sent emails dont respect the users locale nor her personal date- and time formatting settings.

Description of the Change

This PR fixes that, by:

  • Loading the users locale before sending emails & resetting it afterwards
  • Set the current user to the actual member to mail to, to make sure the GatherPress filters for date- and time- format, as well as the users timezone, are recognized by the functions inside render_template()

Closes #

How to test the Change

Testing this PR might be a little tricky and is not possible with WordPress Playground because of the necessary sending & receiving of emails.

Preparation to test:

  1. Setup at least two different users
  2. One of the users creates an event, the other users attends. (This will make sure, 2 emails are sent for the test)
  3. Assign a non-site-default language to one of the users in their profile.php
  4. Go to Updates, get to the bottom of the page and hit the "Update translations" button.
  5. Make sure that in the following screen, the translation files for the selected non-site-default language gets downloaded!

Testing this PR:

  1. Edit the newly created event
  2. Compose a message via Email
  3. Send email
  4. Check the results, one email should follow the user-defined language, while the other is sent in the default locale

Changelog Entry

Fixed - Respect users locale and custom date- and time-formats in sent emails

Credits

Props @carstingaxion

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

…e GatherPress filters for date- and time- format, as well as the users timezone, are recognized by the functions inside render_template().
Copy link

Preview changes with Playground

You can preview the recent changes for PR#922 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@carstingaxion carstingaxion linked an issue Sep 26, 2024 that may be closed by this pull request
1 task
@mauteri mauteri merged commit 0bab53e into GatherPress:main Sep 26, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set user-timezone & user-locale in emails
2 participants